<!-- youtubechannel -->

<!--[if gte IE 9]>
  <style type="text/css">
    .gradient {
       filter: none;
    }
  </style>
<![endif]-->
<script type="text/javascript">
    var yt_html5 = {$yt_html5};
</script>
	<div class="block gradient youtubechannel">
	    <h4>
		    <a href="https://www.youtube.com/user/{$yt_user}?feature=watch" target="_blank" title="{l s='Xem ĐàNẵngPhone trên YouTube' mod='youtubechannel'}">
	            {l s='Chúng tôi trên YouTube' mod='youtubechannel'}
			</a>
		</h4>
	    <div class="block_content">
        {if isset($featured_videos) && $featured_videos == '1'}
			{foreach $videos as $video}
			<script type= "text/javascript">
                    $.ajax({
                        url: "http://gdata.youtube.com/feeds/api/videos/{$video['videoID']}?v=2&alt=json",
                        dataType: "jsonp",
						async: false,
		                cache: true,
                        success: function (data) {
						    var videoTitle = data.entry.title.$t;
							document.getElementById('player_{$video['videoID']}').setAttribute('title', videoTitle);
						}
                    });
            </script>
				{if isset($yt_html5) && $yt_html5 == '1'}
				<a class="player-module" id="player_{$video['videoID']}" href="https://www.youtube.com/embed/{$video['videoID']}&#63;fs=1&amp;theme={if isset($modulecolor) && $modulecolor == '1'}dark{else}light{/if}&amp;color={if isset($iconcolor) && $iconcolor == '1'}red{else}white{/if}&amp;autoplay={$yt_auto_play}&amp;iv_load_policy=3&amp;rel=0&amp;modestbranding=1&amp;controls=2">
					<span class="play2">play</span>
					<img src="https://i.ytimg.com/vi/{$video['videoID']}/0.jpg" alt="" width="{$yt_module_thumb_width}" height="{$yt_module_thumb_height}"/>
				</a>
				{else}
				<a class="player-module" id="player_{$video['videoID']}" href="https://www.youtube.com/v/{$video.videoID}&#63;&version=3&amp;fs=1&amp;theme={if isset($modulecolor) && $modulecolor == '1'}dark{else}light{/if}&amp;color={if isset($iconcolor) && $iconcolor == '1'}red{else}white{/if}&amp;autoplay={$yt_auto_play}&amp;iv_load_policy=3&amp;rel=0&amp;modestbranding=1&amp;controls=2">
				    <span class="play2">play</span>
					<img src="https://i.ytimg.com/vi/{$video['videoID']}/0.jpg" alt="" width="{$yt_module_thumb_width}" height="{$yt_module_thumb_height}"/>
				</a>
				{/if}
            {/foreach}
		{else}
		<script type="text/javascript">
			function showModuleVideos(data) {
                var feed = data.feed;
                var entries = feed.entry || [];
                var html = ['<ul>'];
                for (var i = 0; i < entries.length; i++) {
					var entry = entries[i];
                    var moduleTitle = entry.title.$t;
					var modulethumbnailUrl = entry.media$group.media$thumbnail[0].url;
					var url = entry.id.$t;
                    id = url.replace("http://gdata.youtube.com/feeds/videos/", "");

					if(yt_html5==1){
		                moduleplayerUrl = "https://www.youtube.com/embed/"+id;
	                }else{
	                    moduleplayerUrl = "https://www.youtube.com/v/"+id;
	                }
                    html.push('<li>' +
					'<a class="player-module" id="module_', id,'" href="', moduleplayerUrl,'?fs=1&theme={if isset($modulecolor) && $modulecolor == '1'}dark{else}light{/if}&color={if isset($iconcolor) && $iconcolor == '1'}red{else}white{/if}&amp;autoplay={$yt_auto_play}&amp;iv_load_policy=3&amp;rel=0&amp;modestbranding=1&amp;controls=2" title="', moduleTitle,'">',
					'<span class="play2">play<\/span>',
					'<img src="', modulethumbnailUrl,'" width="{$yt_module_thumb_width}" height="{$yt_module_thumb_height}" />',
					'<\/a>',
					'<\/li>');
                }
                    html.push('<\/ul>');
                    document.getElementById('videosmodule').innerHTML = html.join('');
            }
		</script>
			<div id="videosmodule"></div>
			    <script type="text/javascript" src="https://gdata.youtube.com/feeds/users/{$yt_user}/uploads?alt=json-in-script&amp;format=5&amp;max-results=2&amp;orderby={$yt_module_order}&amp;iv_load_policy=3&amp;rel=0&amp;modestbranding=1&amp;controls=2&amp;callback=showModuleVideos"></script>
			{/if}
			<p class="morevideos">
			    <a id="viewmore" class="yt_button" href="{$link->getPageLink('youtubechannel.php', false)}" title="{l s='Xem video khác' mod='youtubechannel'}">{l s='Xem video khác' mod='youtubechannel'}</a>
			</p>
		</div>
	</div>
<script type="text/javascript">
	$(document).ready(function() {
		var player = 'swf';
		if(yt_html5==1){
		    player = 'iframe';
		}
	        $(".player-module").fancybox({
				'padding'		: 0,
				'autoScale'		: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'centerOnScroll': true,
				'titleShow'		: this.title,
				'width'		    : {$yt_player_width},
				'height'		: {$yt_player_height},
				'type'			: player
			});
		return false;
    });
</script>
<div class="clear"></div>
<!-- /youtubechannel -->